<template>
	<view>
		<view class="teacher" @click="goToTeacherDetail(teacherId)">
			<view class="title">
				教师
			</view>
			<view class="content">
				<view class="avatar">
					<image :src="teacherData.cover_100" mode="widthFix"></image>
				</view>
				<view class="info">
					<view class="title">{{teacherData.name}}</view>
					<view class="description text-ellipsis-2">{{teacherData.description}}</view>
				</view>
				<view class="action">
					<uni-icons type="arrowright" size="14" color="#999999"></uni-icons> 
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'Teacher',
		props:{
			teacherId: {
				type: Number,
				default: ''
			},
			teacherData: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				
			}
		},
		created() {
			this.$nextTick(() => {
				this.getTeacherInfoHeight();
			})
		},
		methods: {
			/**
			 * 获取高度
			 */
			getTeacherInfoHeight() {
				const query = uni.createSelectorQuery().in(this);
				query.select('.teacher').boundingClientRect(data => {
					console.log(data.height)
					this.$emit("setTeacherInfoHeight", data.height);
				}).exec();
			},
			
			goToTeacherDetail: function(teacher_id){
				let urlParams = 'id='+teacher_id
				let url = '/muu_classroom/pages/teacher/detail?' + urlParams
				//指定跳转地址
				uni.navigateTo({
				    url: url
				});
			}
		}
	}
</script>

<style lang="scss">
	.teacher {
		background-color: #fff;
		margin-bottom: 20rpx;
		padding: 20rpx;
		.title {
			font-size: 28rpx;
			font-weight: 600;
			color: #000;
			margin-bottom: 16rpx;
		}
		.content {
			display: flex;
			.avatar {
				width: 120rpx;
				height: 120rpx;
				border-radius: 50%;
				overflow: hidden;
				image {
					width: 100%;
				}
			}
			.info {
				flex: 1;
				padding-left: 20rpx;
				.title {
					display: block;
					color: #000;
					font-size: 28rpx;
				}
				.description {
					color: #666;
					font-size: 24rpx;
				}
			}
		}
		.action {
			width: 40rpx;
			text-align: center;
			line-height: 120rpx;
		}
	}
</style>
